# -*- coding:utf-8 -*-  

# Contact with the author by :
# itech001@126.com
# www.cnblogs.com/itech

import os
import sys
import socket

import PyRRClientLib

if __name__ == "__main__":
    usage = """
    Usage:
    sys.argv[0] HOST PORT "-c:cmd|-sf:scriptfilename"
    Function:
    excute cmd by "-c:cmd"
    excute script file by "-sf:scriptfilename"
    Notes:
    make sure the port is allowed by fireware.  

    Defaulty connect to localhost:9999
    """


    host, port = "localhost",9999
    cmd_or_scriptfn = ''
    if(len(sys.argv) >= 2):    host = sys.argv[1]
    if(len(sys.argv) >= 3):    port = int(sys.argv[2])
    if(len(sys.argv) >= 4):
      cmd_or_scriptfn = sys.argv[3]
      PyRRClientLib.remote_running_client(host, port, cmd_or_scriptfn)
    else:
      print("Error: no enough parameters!")
      print(usage)